package com.yesorno.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextPaint;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

/**
 * 评论的菜单
 * 
 * @author samoin
 * @version 0.1
 * @since 2011-08-08
 * 
 */
public class CommentMenuActivity extends Activity {

	private RelativeLayout comment_menu_go;
	private RelativeLayout comment_menu_add;

	private long currentTopicId = 0;
	private int type = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.comment_menu);

		TextView comment_menu_title = (TextView) findViewById(R.id.comment_menu_title);
		TextPaint tp = comment_menu_title.getPaint();
		tp.setFakeBoldText(true);

		comment_menu_go = (RelativeLayout) findViewById(R.id.comment_menu_go);
		comment_menu_add = (RelativeLayout) findViewById(R.id.comment_menu_add);
		MyOnClickListener mocl = new MyOnClickListener();
		comment_menu_go.setOnClickListener(mocl);
		comment_menu_add.setOnClickListener(mocl);
		Intent intent = getIntent();
		currentTopicId = intent.getLongExtra("currentTopicId", 0);
		type = intent.getIntExtra("type", 0);
	}

	class MyOnClickListener implements OnClickListener {

		@Override
		public void onClick(View v) {
			if (v == comment_menu_go) {
				// TODO 这里将来要请求后台进行评论的记录
				Intent intent = new Intent();
				// intent.putExtra("result", -1);
				// intent.putExtra("msg", "评论失败，不能重复评论");
				intent.putExtra("result", 0);
				intent.putExtra("msg", "评论成功");
				intent.putExtra("type", type);
				CommentMenuActivity.this.setResult(RESULT_OK, intent);
				CommentMenuActivity.this.finish();
			}
			if (v == comment_menu_add) {
				Intent intent = new Intent();
				intent.putExtra("currentTopicId", currentTopicId);
				intent.putExtra("type", type);
				intent.setClass(CommentMenuActivity.this,
						TopicCommentActivity.class);
				startActivity(intent);
				finish();
			}
		}

	}

}
